var status = -1;
var selectionLog = [];
var level = 0;

function start() {
    action(1, 0, 0)
}

function action(mode, type, selection) {
    if (status == 0 && mode == 0) {
        cm.dispose();
        return
    }
    status++;
    selectionLog[status] = selection;
    var i = -1;
    if (status <= i++) {
        cm.dispose()
    } else {
        if (status === i++) {
            if (!cm.isQuestFinished(41903)) {
                cm.sendNormalTalk("神之子，请继续在冒险岛世界和镜世界中冒险。没有什么东西比冒险和经验更加重要。有关专业技术的课程最好等之后再进行。", 0, 2400001, false, false);
                cm.dispose()
            } else {
                var text = "专业技术就交给我戴尔罗吧！\r\n只要做到学习、熟悉、理解就可以了。\r\n#L0##b#e了解药草采集#k#n#l\r\n#L1##b#e了解采矿#k#n#l";
                if (cm.hasSkill(92020000)) {
                    text += "\r\n#L5##b#e了解装备制作#k#n#l\r\n#L6##b#e初始化装备制作#k#n#l"
                } else {
                    if (cm.hasSkill(92030000)) {
                        text += "\r\n#L7##b#e了解饰品制作#k#n#l\r\n#L8##b#e初始化饰品制作#k#n#l"
                    } else {
                        if (cm.hasSkill(92040000)) {
                            text += "\r\n#L9##b#e了解炼金术#k#n#l\r\n#L10##b#e初始化炼金术#k#n#l"
                        } else {
                            text += "\r\n#L2##b#e学习装备制作#k#n#l\r\n#L3##b#e学习饰品制作#k#n#l\r\n#L4##b#e学习炼金术#k#n#l"
                        }
                    }
                }
                cm.askMenu(text, 0, 2400001)
            }
        } else {
            var reactor = "action分支" + selectionLog[1];
            eval(reactor)(mode, type, selection, i)
        }
    }
}

function action分支0(e, d, c, b) {
    if (status <= b++) {
        cm.sendNormalTalk("学习药草采集需要花费#b1000金币#k和#b疲劳度5#k。只要按照我的讲座，就可以获得#r80#k熟练度。", 0, 2400001, false, true)
    } else {
        if (status === b++) {
            cm.gainMeso(-5000);
            cm.getPlayer().setFatigue(cm.getPlayer().getFatigue() + 5);
            var a = 92000000;
            level = cm.rand(0, 3);
            cm.getPlayer().addProfessionExp(a, 80 + level * 10);
            cm.zeroLearnProfessionSkill(a, level, 80 + level * 10, 0);
            cm.dispose()
        }
    }
}

function action分支1(e, d, c, b) {
    if (status <= b++) {
        cm.sendNormalTalk("学习矿物采集需要花费#b1000金币#k和#b疲劳度5#k。只要按照我的讲座，就可以获得#r80#k熟练度。", 0, 2400001, false, true)
    } else {
        if (status === b++) {
            cm.gainMeso(-5000);
            cm.getPlayer().setFatigue(cm.getPlayer().getFatigue() + 5);
            var a = 92010000;
            level = cm.rand(0, 3);
            cm.getPlayer().addProfessionExp(a, 80 + level * 10);
            cm.zeroLearnProfessionSkill(a, level, 80 + level * 10, 0);
            cm.dispose()
        }
    }
}

function action分支5(e, d, c, b) {
    if (status <= b++) {
        cm.sendNormalTalk("学习装备制作需要花费#b1000金币#k和#b疲劳度5#k。只要按照我的讲座，就可以获得#r80#k熟练度。", 0, 2400001, false, true)
    } else {
        if (status === b++) {
            cm.gainMeso(-5000);
            cm.getPlayer().setFatigue(cm.getPlayer().getFatigue() + 5);
            var a = 92020000;
            level = cm.rand(0, 3);
            cm.getPlayer().addProfessionExp(a, 80 + level * 10);
            cm.zeroLearnProfessionSkill(a, level, 10 + level * 30, 0);
            cm.dispose()
        }
    }
}

function action分支7(e, d, c, b) {
    if (status <= b++) {
        cm.sendNormalTalk("学习饰品制作需要花费#b1000金币#k和#b疲劳度5#k。只要按照我的讲座，就可以获得#r80#k熟练度。", 0, 2400001, false, true)
    } else {
        if (status === b++) {
            cm.gainMeso(-5000);
            cm.getPlayer().setFatigue(cm.getPlayer().getFatigue() + 5);
            var a = 92030000;
            level = cm.rand(0, 3);
            cm.getPlayer().addProfessionExp(a, 80 + level * 10);
            cm.zeroLearnProfessionSkill(a, level, 80 + level * 10, 0);
            cm.dispose()
        }
    }
}

function action分支9(e, d, c, b) {
    if (status <= b++) {
        cm.sendNormalTalk("学习炼金术需要花费#b1000金币#k和#b疲劳度5#k。只要按照我的讲座，就可以获得#r80#k熟练度。", 0, 2400001, false, true)
    } else {
        if (status === b++) {
            cm.gainMeso(-5000);
            cm.getPlayer().setFatigue(cm.getPlayer().getFatigue() + 5);
            var a = 92040000;
            level = cm.rand(0, 3);
            cm.getPlayer().addProfessionExp(a, 80 + level * 10);
            cm.zeroLearnProfessionSkill(a, level, 80 + level * 10, 0);
            cm.dispose()
        }
    }
}

function action分支2(d, c, b, a) {
    if (status <= a++) {
        cm.askYesNo("学习#b装备制作#k，需要花费#b5000金币#k。真的要学习吗？", 0, 2400001);
        cm.gainSkillBuff(100001263)
    } else {
        if (status === a++) {
            if (d != 1) {
                cm.sendNormalTalk("好的，你深思熟虑之后再回答吧。要慎重地选择才不会后悔！", 0, 2400001, false, true)
            } else {
                if (cm.getMeso() < 5000) {
                    cm.sendNormalTalk("你的金币不够啊。", 0, 2400001, false, true)
                } else {
                    cm.gainMeso(-5000);
                    cm.teachSkill(92020000, 16777216, 0);
                    cm.fieldEffect_PlayFieldSound("profession/levelup", 100);
                    cm.sendNormalTalk("学习装备制作成功，如果对装备制作想了解更多的话，随时可以来找我。", 0, 2400001, false, true);
                    cm.effect_OnUserEff("Effect/OnUserEff.img/professions/equip_product_levelup")
                }
            }
        } else {
            if (status === a++) {
                cm.dispose()
            }
        }
    }
}

function action分支3(d, c, b, a) {
    if (status <= a++) {
        cm.askYesNo("学习#b饰品制作#k，需要花费#b5000金币#k。真的要学习吗？", 0, 2400001);
        cm.gainSkillBuff(100001263)
    } else {
        if (status === a++) {
            if (d != 1) {
                cm.sendNormalTalk("好的，你深思熟虑之后再回答吧。要慎重地选择才不会后悔！", 0, 2400001, false, true)
            } else {
                if (cm.getMeso() < 5000) {
                    cm.sendNormalTalk("你的金币不够啊。", 0, 2400001, false, true)
                } else {
                    cm.gainMeso(-5000);
                    cm.teachSkill(92030000, 16777216, 0);
                    cm.fieldEffect_PlayFieldSound("profession/levelup", 100);
                    cm.sendNormalTalk("学习饰品制作成功，如果对饰品制作想了解更多的话，随时可以来找我。", 0, 2400001, false, true);
                    cm.effect_OnUserEff("Effect/OnUserEff.img/professions/equip_product_levelup")
                }
            }
        } else {
            if (status === a++) {
                cm.dispose()
            }
        }
    }
}

function action分支4(d, c, b, a) {
    if (status <= a++) {
        cm.askYesNo("学习#b炼金术#k，需要花费#b5000金币#k。真的要学习吗？", 0, 2400001);
        cm.gainSkillBuff(100001263)
    } else {
        if (status === a++) {
            if (d != 1) {
                cm.sendNormalTalk("好的，你深思熟虑之后再回答吧。要慎重地选择才不会后悔！", 0, 2400001, false, true)
            } else {
                if (cm.getMeso() < 5000) {
                    cm.sendNormalTalk("你的金币不够啊。", 0, 2400001, false, true)
                } else {
                    cm.gainMeso(-5000);
                    cm.teachSkill(92040000, 16777216, 0);
                    cm.fieldEffect_PlayFieldSound("profession/levelup", 100);
                    cm.sendNormalTalk("学习炼金术成功，如果对炼金术想了解更多的话，随时可以来找我。", 0, 2400001, false, true);
                    cm.effect_OnUserEff("Effect/OnUserEff.img/professions/equip_product_levelup")
                }
            }
        } else {
            if (status === a++) {
                cm.dispose()
            }
        }
    }
}

function action分支6(d, c, b, a) {
    if (status <= a++) {
        cm.askYesNo("你想放弃装备制作？是厌倦了吗？之前积累的等级和熟练度……付出的努力和金钱……都将会变成泡影……你真的要初始化吗？", 0, 2400001);
        cm.gainSkillBuff(100001263)
    } else {
        if (status === a++) {
            if (d != 1) {
                cm.sendNormalTalk("好的，你深思熟虑之后再回答吧。要慎重地选择才不会后悔！", 0, 2400001, false, true)
            } else {
                cm.teachSkill(92020000, 0, 0);
                cm.sendNormalTalk("装备制作已经初始化。如果想重新学习，请再来找我。", 0, 2400001, false, true)
            }
        } else {
            if (status === a++) {
                cm.dispose()
            }
        }
    }
}

function action分支8(d, c, b, a) {
    if (status <= a++) {
        cm.askYesNo("你想放弃饰品制作？是厌倦了吗？之前积累的等级和熟练度……付出的努力和金钱……都将会变成泡影……你真的要初始化吗？", 0, 2400001);
        cm.gainSkillBuff(100001263)
    } else {
        if (status === a++) {
            if (d != 1) {
                cm.sendNormalTalk("好的，你深思熟虑之后再回答吧。要慎重地选择才不会后悔！", 0, 2400001, false, true)
            } else {
                cm.teachSkill(92030000, 0, 0);
                cm.sendNormalTalk("饰品制作已经初始化。如果想重新学习，请再来找我。", 0, 2400001, false, true)
            }
        } else {
            if (status === a++) {
                cm.dispose()
            }
        }
    }
}

function action分支10(d, c, b, a) {
    if (status <= a++) {
        cm.askYesNo("你想放弃炼金术？是厌倦了吗？之前积累的等级和熟练度……付出的努力和金钱……都将会变成泡影……你真的要初始化吗？", 0, 2400001);
        cm.gainSkillBuff(100001263)
    } else {
        if (status === a++) {
            if (d != 1) {
                cm.sendNormalTalk("好的，你深思熟虑之后再回答吧。要慎重地选择才不会后悔！", 0, 2400001, false, true)
            } else {
                cm.teachSkill(92040000, 0, 0);
                cm.sendNormalTalk("炼金术已经初始化。如果想重新学习，请再来找我。", 0, 2400001, false, true)
            }
        } else {
            if (status === a++) {
                cm.dispose()
            }
        }
    }
};